<template>
  <header class="top-navber">
    <div class="frosted-glass">
      <div class="logo-box" title="南棠REP">
        <img src="~@/assets/img/Logo/logo.png" class="ERP_logo" alt />
        <h2>南棠ERP</h2>
      </div>
      <div class="logo-dropdown">
        <div class="user-name">{{userName}}</div>
        <div class="user-operating">
          <el-dropdown trigger="click" @command="operatingFun">
            <span class="el-dropdown-link">
              <img src="~@/assets/img/Logo/logo.png" class="ERP_logo" alt /><i
                class="el-icon-arrow-down el-icon-caret-bottom"
              ></i>
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item icon="el-icon-key" command="1"
                  >修改密码</el-dropdown-item
                >
                <el-dropdown-item divided icon="el-icon-unlock" command="2"
                  >退出登录</el-dropdown-item
                >
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </div>
    </div>
  </header>
</template>
<script>
import { inject } from "vue";
export default {
  name: "TopNavber",
  components: {},
  porps: {
    // userName: String,
  },
  setup(porps, { emit }) {
    const userName = inject("userName");

    const operatingFun = (str) => {
      switch (str) {
        case "1":
          emit("eidtPass");
          break;
        case "2":
          emit("logout");
          break;
      }
    };

    return {
      operatingFun,
      userName,
    };
  },
};
</script>


<style lang="scss">
.el-dropdown__popper.el-popper.is-light.is-pure {
  top: 80px !important;
  .el-dropdown-menu__item {
    font-size: 16px;
  }
}
.top-navber {
  width: 100vw;
  height: 60px;
  box-sizing: border-box;
  line-height: 60px;
  // background: rgba(255, 255, 255, 0.5)
  //   url("~@/assets/img/Taxonomy/after-sale.png");
  background: linear-gradient(141deg, #56ccf2, #2f80ed 90%);
  z-index: 99;
  .frosted-glass {
    width: 100%;
    height: 100%;
    padding: 0 20px 0 40px;
    -webkit-transition: all 0.5s;
    transition: all 0.5s;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    &:hover {
      backdrop-filter: blur(3px);
    }
    .logo-box {
      min-width: 150px;
      height: 50px;
      display: flex;
      justify-content: space-between;
      .ERP_logo {
        width: 40px;
        height: 39px;
        margin: 10px 15px 0 0;
        border-radius: 50%;
        /*animation (动画) :绑定选择器, 4s完成动画 linear(匀速) infinite(循环) */
        animation: loading 3s linear infinite;
      }
      h2 {
        color: #fff;
      }
    }
    .logo-dropdown {
      min-width: 170px;
      display: flex;
      justify-content: space-between;
      .user-name {
        height: 100%;
        padding: 0 10px;
        margin: 0 10px;
        text-align: center;
        font-size: 22px;
        color: #f5f5f5;
        transition: 0.5s;
        &:hover {
          background-color: rgba(0, 0, 0, 0.1);
        }
      }
      .user-operating {
        img {
          width: 40px;
          height: 40px;
          margin: 10px 8px 0 15px;
          border-radius: 5px;
        }
        &:hover {
          background-color: rgba(0, 0, 0, 0.1);
        }
        .el-dropdown-link {
          color: #f5f5f5;
          .el-dropdown-menu {
            width: 500px;
          }
        }
      }
    }
  }
}
/*通过@keyframes规则,能够创建动画 , que 定义动画的名称 可自己定义*/
@keyframes loading {
  /*以百分比来规定改变发生的时间 也可以通过"from"和"to",等价于0% 和 100%*/
  0% {
    /*rotate(2D旋转) scale(放大或者缩小) translate(移动) skew(翻转)*/
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
</style>